import base
from imgaug import augmenters as iaa
import random
import time

def getRandomCutPercent():
    vct_cut = random.uniform(0.3,0.65)
    hor_cut = vct_cut * random.uniform(0.75,1.25)

    top_cut = random.uniform(0,vct_cut)
    right_cut = random.uniform(0,hor_cut)
    buttom_cut = vct_cut-top_cut
    left_cut = hor_cut -right_cut

    percent = (top_cut,right_cut,buttom_cut,left_cut)
    return percent


start = time.time()

ids = base.load_ids()
ids_length = len(ids)

for i in range(ids_length*5):
    id = ids[i%ids_length]
    percent = getRandomCutPercent()
    keep_size = random.random() < 0.2
    new_id = "%s-%s-%s_%f_%f_%f_%f"%(id,'crop',keep_size,percent[0],percent[1],percent[2],percent[3])

    aug = iaa.Crop(percent=percent,keep_size=keep_size)

    # base.augmenttation_handle(id,aug,new_id,False,0.99)
    print("%d Spent:%f"%(i,time.time() -start))


